package cqut.wys.controller;

import cqut.wys.dao.entity.User;
import cqut.wys.dao.mapper.user.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * --------神兽出没--------/
 *   ┌─┐     ┌─┐
 * ┌─┘─┴─────┘─┴─┐
 * │      ─      │
 * │  ┬─┘   └─┬  │
 * │             │
 * │      ┴      │  Code is far away from bug with the animal protecting
 * └───┐      ┌──┘  神兽保佑,代码无bug
 *     │      │
 *     │      └──────┐
 *     │             ├┐
 *     │             ┌┘
 *     └┐ ┐ ┌───┬─┐ ┌┘
 *      │ ┤ ┤   │ ┤ ┤
 *      └─┴─┘   └─┴─┘
 * --------感觉萌萌哒--------/
 *
 * @author wuyoushan
 * @date 2018/2/28
 */
@RestController
public class UserController {

    @Autowired
    UserMapper userMapper;

    @GetMapping("/getUser/{id}")
    public User getUser(@PathVariable Integer id ){
        return userMapper.findUserById(id);
    }

    @GetMapping("/saveUser")
    @Transactional(rollbackFor = RuntimeException.class)
    public int saveUser(User user){
        user = new User();
        user.setName("dsfgsdf");
        user.setAge(12);
        user.setGender("男");
        userMapper.addUser(user);
        int b = 0;
        int a = 1;
        int c =a/b;
        return userMapper.addUser(user);
    }
}
